package com.asa.voice.mp3.asa.decoder;


public class AudioBuffer {
  protected byte[] pcmbuf;
  
  protected int[] off;
  
  private IAudio audio;
  
  private int size;
  
  public AudioBuffer(IAudio paramIAudio, int paramInt) {
    this.audio = paramIAudio;
    this.size = paramInt;
    this.pcmbuf = new byte[paramInt];
    this.off = new int[] { 0, 2 };
  }
  
  public void output() {
    if (this.off[0] == this.size) {
      if (this.audio != null)
        this.audio.write(this.pcmbuf, this.size); 
      this.off[0] = 0;
      this.off[1] = 2;
    } 
  }
  
  public void flush() {
    if (this.audio != null) {
      this.audio.write(this.pcmbuf, this.off[0]);
      this.audio.drain();
    } 
    this.off[0] = 0;
    this.off[1] = 2;
  }
}
